﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LevelShutPanel : MonoBehaviour
{
    public Text SucceedL;
    public Text LoseL;
    public Text SucceedDescriptionL;
    public Text LoseDescriptionL;
    public GameObject SopilsOfWarGrad;
    public ItemPerviewIcon ItemPerviewPerfab;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void Succeed(List<Item> items)
    {
        SucceedL.gameObject.SetActive(true);
        LoseL.gameObject.SetActive(false);
        SucceedDescriptionL.gameObject.SetActive(true);
        LoseDescriptionL.gameObject.SetActive(false);
        foreach (var item in items)
        {
            var obj = Instantiate(ItemPerviewPerfab);
            var objCom = obj.GetComponent<ItemPerviewIcon>();
            objCom.Item = item;
            obj.transform.SetParent(SopilsOfWarGrad.transform);
            obj.transform.localScale = new Vector3(1,1,1);
        }
    }

    public void Lose(List<Item> items)
    {
        SucceedL.gameObject.SetActive(false);
        LoseL.gameObject.SetActive(true);
        SucceedDescriptionL.gameObject.SetActive(false);
        LoseDescriptionL.gameObject.SetActive(true);

        foreach (var item in items)
        {
            var obj = Instantiate(ItemPerviewPerfab);
            var objCom = obj.GetComponent<ItemPerviewIcon>();
            objCom.Item = item;
            obj.transform.SetParent(SopilsOfWarGrad.transform);
            obj.transform.localScale = new Vector3(1, 1, 1);
        }
    }
}
